import * as type from '../types'
import {
    _getAllCollege,
    _getTeacherRatio,
    _getTeacherAgeRange,
    _findCollegeProjectAndPaperNum,
    _findDepartmentTeacherTop5
} from '@/api/data'

const state = {
    allCollege: [],
    teacherRatio:[],
    teacherAge:[],
    project_parernum:{},
    teacherTop:[]
}

const actions = {
    async getAllCollege({commit}, params) {
        let res = await _getAllCollege(params)
        if(res&&res.status){
            commit(type.GET_ALL_COLLAGE, res.data)
        }
    },
    async getTeacherRatio({commit}, params) { 
        let res = await _getTeacherRatio(params)
        if(res&&res.status){
            commit(type.GET_TEACHER_RATIO, res.data)
        }
    },
    async getTeacherAgeRange({commit}, params) { 
        let res = await _getTeacherAgeRange(params)
        if(res&&res.status){
            commit(type.GET_TEACHER_AGE_RANGE, res.data)
        }
    },
    async findCollegeProjectAndPaperNum({commit}, params) { 
        let res = await _findCollegeProjectAndPaperNum(params)
        if(res&&res.status){
            commit(type.GET_PROJECT_PAPERNUM, res.data)
        }
    },
    async findDepartmentTeacherTop5({commit}, params) { 
        let res = await _findDepartmentTeacherTop5(params)
        if(res&&res.status){
            commit(type.GET_TOP, res.data)
        }
    }
}

const mutations = {
    [type.GET_ALL_COLLAGE] (state, payload) {
        state.allCollege = payload
    },
    [type.GET_TEACHER_RATIO] (state, payload) {
        state.teacherRatio = payload
    },
    [type.GET_TEACHER_AGE_RANGE] (state, payload) {
        state.teacherAge = payload
    },
    [type.GET_PROJECT_PAPERNUM] (state, payload) {
        state.project_parernum = payload
    },
    [type.GET_TOP] (state, payload) {
        state.teacherTop = payload
    }
  }

export default {
    namespaced: true,
    state,
    actions,
    mutations
}